<?php
/**
 * Created by PhpStorm.
 * User: boye009
 * Date: 2016/3/16
 * Time: 14:01
 */

namespace app\index\domain;

use app\index\domain\BaseDomain;
use app\bbs\api\ForumForumApi;
use app\bbs\api\ForumThreadApi;

// use Bbs\Api\ForumAttachmentApi;
// use Bbs\Api\ForumPostApi;

class ForumForumDomain extends BaseDomain{
    protected $business_code = 'forumForum';

    //论坛版块分页
    //最多二级板块 0正常/-1关闭/1锁定
    public function query(){
        $this->checkVersion($this->api_ver);
        addLog("ForumForum/query", $_GET, $_POST, $this->client_id . "调用论坛版块查询接口!");
        if(IS_POST){
            $fup = $this -> _post('up_fid',0);
            // $fid = $this -> _post('fid','');
            // $num = $this -> _post('num',10);
            $order = "displayorder asc";
            $map = [
                'fup'     => $fup,
                '_string' =>' status>-1 ',
            ];

            $result = apiCall(ForumForumApi::QUERY_NO_PAGING,array($map,$order,false));
            // $this -> apiReturnErr($result);
            if($result['status'] && !empty($result['info'])){
                // foreach ($result['info'] as $k => &$v) {
                //     $v['icon_url'] = getImageUrl($v['icon_id']);
                // }
                // $list['list'] = $result['info'];
                // foreach($list['list'] as &$val){
                //     //判断是否含有子论坛
                //     $map = ['fup' => $val['fid']];
                //     $result = apiCall(ForumForumApi::COUNT,array($map));
                //     if(!$result['status']) $this -> apiReturnErr('服务器故障: forum forum count');
                //     $val['has_child'] = $result['info']?1:0;
                // }
                // if(empty($fid)) $fid = $list['list'][0]['fid'];
                // //查询$num个$fid板块的帖子
                // $result = apiCall(ForumThreadApi::QUERY_PAGE,[$fid,1,$num]);
                // $this -> apiReturnErr($result);
                // if($result['status']){
                //     $list['thread'] = $result['info'];
                // }else{
                //     $this -> apiReturnErr('服务器故障: forum thread page');
                // }

                $this -> apiReturnSuc($result['info']);
            }else{
                $this -> apiReturnErr($result['info']);
            }
        }

    }

    /**
     * 查询用户信息
     */
    // private function getUserInfo($uid){
    //     $result = apiCall('Api/BbsUserCenter/userInfo',array($uid),'Domain');
    //     if($result['status']){
    //         return $result['info'];
    //     }else{
    //         $this->apiReturnErr('查询用户信息失败');
    //     }
    // }

}